package com.example.administrator.newsapp.StatusBarUtils;

import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;

public class SetActionBarHeight {
    //构造函数，传入需要计算高度的空间id和它的父控件view
    public SetActionBarHeight(View v, int viewId) {
        View view=v.findViewById(viewId);
        //获取到view的布局参数
        LinearLayout.LayoutParams layoutParams=(LinearLayout.LayoutParams) view.getLayoutParams();
        //获取到view的actionbar的高度
        int height=view.getResources().getIdentifier("status_bar_height","dimen","android");
        //转化为像素值
        int res=view.getResources().getDimensionPixelSize(height);
        //将结果赋给view的高度
        layoutParams.height=res;

        //重新社会好布局参数
        view.setLayoutParams(layoutParams);
    }


}
